package com.lzw.dto;

import com.lzw.utils.JsonUtils;
import lombok.Data;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author liuzw
 * @date 2024/1/3
 */
@Data
public class Student implements Serializable {
    private String name;
    private boolean sex;
    private Integer age;

    public Student() {
    }

    public Student(String json) {
        BeanUtils.copyProperties(JsonUtils.toBean(json, this.getClass()), this);
    }

    @Override
    public String toString() {
        return new Jackson2JsonMessageConverter().toMessage(this, new MessageProperties()).toString();
    }

}
